@@ -4,16 +4,20 @@ import logging |
||
4 | 4 |
|
5 | 5 |
from django.conf import settings |
6 | 6 |
from django.db import transaction |
7 |
+from django_redis_connector import connector |
|
7 | 8 |
from django_six import CompatibilityBaseCommand, close_old_connections |
8 | 9 |
from django_we.models import SubscribeUserInfo |
9 | 10 |
from pywe_storage import RedisStorage |
10 | 11 |
from pywe_user import get_user_info |
11 | 12 |
|
12 | 13 |
from account.models import UserInfo |
13 |
-from utils.redis.connect import r |
|
14 |
+from mch.models import BrandInfo |
|
14 | 15 |
from utils.redis.rkeys import SUBSCRIBE_USERINFO_LIST |
15 | 16 |
|
16 | 17 |
|
18 |
+r1 = connector(settings.REDIS.get('db1', {})) |
|
19 |
+ |
|
20 |
+ |
|
17 | 21 |
WECHAT = settings.WECHAT |
18 | 22 |
|
19 | 23 |
|
@@ -25,12 +29,15 @@ class Command(CompatibilityBaseCommand): |
||
25 | 29 |
|
26 | 30 |
logger.info('SubscribeUserInfo is dealing') |
27 | 31 |
|
32 |
+ brands = BrandInfo.objects.filter(status=True) |
|
33 |
+ subscribe_keys = [SUBSCRIBE_USERINFO_LIST % brand.brand_id for brand in brands] |
|
34 |
+ |
|
28 | 35 |
while True: |
29 | 36 |
# r.rpushjson('SUBSCRIBE_USERINFO_LIST', { |
30 | 37 |
# 'brand_id': 'brand_id', |
31 | 38 |
# 'openid': 'openid', |
32 | 39 |
# }) |
33 |
- k, v = r.blpopjson(SUBSCRIBE_USERINFO_LIST, 60) |
|
40 |
+ k, v = r1.blpopjson(subscribe_keys, 60) |
|
34 | 41 |
if not v: |
35 | 42 |
continue |
36 | 43 |
|
@@ -216,6 +216,13 @@ REDIS = { |
||
216 | 216 |
'USER': '', |
217 | 217 |
'PASSWORD': '', |
218 | 218 |
'db': 0, |
219 |
+ }, |
|
220 |
+ 'db1': { |
|
221 |
+ 'HOST': '127.0.0.1', |
|
222 |
+ 'PORT': 6379, |
|
223 |
+ 'USER': '', |
|
224 |
+ 'PASSWORD': '', |
|
225 |
+ 'db': 1, |
|
219 | 226 |
} |
220 | 227 |
} |
221 | 228 |
|
@@ -1,6 +1,7 @@ |
||
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 | 3 |
from django.conf import settings |
4 |
+from django_redis_connector import connector |
|
4 | 5 |
from pywe_storage import RedisStorage |
5 | 6 |
from pywe_user import get_all_users |
6 | 7 |
|
@@ -8,6 +9,9 @@ from utils.redis.connect import r |
||
8 | 9 |
from utils.redis.rkeys import SUBSCRIBE_USERINFO_LIST |
9 | 10 |
|
10 | 11 |
|
12 |
+r1 = connector(settings.REDIS.get('db1', {})) |
|
13 |
+ |
|
14 |
+ |
|
11 | 15 |
WECHAT = settings.WECHAT |
12 | 16 |
|
13 | 17 |
|
@@ -15,7 +19,7 @@ def fetch_users_func(authorizer_appid, infos): |
||
15 | 19 |
print authorizer_appid, infos |
16 | 20 |
openids = infos.get('data', {}).get('openid', []) |
17 | 21 |
for openid in openids: |
18 |
- r.rpushjson(SUBSCRIBE_USERINFO_LIST, { |
|
22 |
+ r1.rpushjson(SUBSCRIBE_USERINFO_LIST, { |
|
19 | 23 |
'brand_id': authorizer_appid, |
20 | 24 |
'openid': openid |
21 | 25 |
}) |
@@ -76,4 +76,4 @@ REDPACK_WAITING_SEND_LIST = 'tamron:redpack:waiting:send' # |
||
76 | 76 |
|
77 | 77 |
MEMBERCARD_USERINFO_LIST = 'tamron:membercard:userinfo' # |
78 | 78 |
|
79 |
-SUBSCRIBE_USERINFO_LIST = 'subscribe:userinfo' |
|
79 |
+SUBSCRIBE_USERINFO_LIST = 'subscribe:userinfo:%s' |